function bubblesort(arr){
    for(let i = 0; i < arr.length; i++){
        for(let j = 0; j < arr.length - i - 1; j++){
            if(arr[j] > arr[j+1]){
                [arr[j], arr[j+1]] = [arr[j+1], arr[j]]
            }
        }
    }
    return arr;
}

console.log(bubblesort([5,4,3,2,1]))
console.log(bubblesort([1,2,3,4,5]))
console.log(bubblesort([5,4,3,2,1]))
console.log(bubblesort([3,2,4,5,1]))
